package com.tuzhi.filestore.mq.producter;

import com.tuzhi.filestore.mq.config.Constant;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 功能说明：
 *
 * @author abu
 * @version 1.1.0
 * @date 2023/2/20
 */
@Transactional
@Service("producer")
public class MsgProducter {

    @Autowired
    RabbitTemplate rabbitTemplate;

    public void sendMsg(String routingKey, Message mqMsg) {
        sendMsg(Constant.topicExchange, routingKey, mqMsg);
    }

    public void sendMsg(String topicExchange, String routingKey, Message mqMsg) {
        rabbitTemplate.convertAndSend(topicExchange, routingKey, mqMsg);
    }
}
